/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.tue.nl.aa;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author waldo
 */
public class ExecuteAlgorithm {
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception{
        File file = new File(args[0]);
        String line;
        ArrayList<JobDTO> jobs = new ArrayList<JobDTO>();
        try {
            BufferedReader br = new BufferedReader(new FileReader(file));
            while( (line = br.readLine()) != null ){
                jobs.add( new JobDTO( Double.parseDouble(line) ) );
            }
        } catch (IOException ex) {
            Logger.getLogger(ExecuteAlgorithm.class.getName()).log(Level.SEVERE, null, ex);
        }
        OrderedSchedulingAlgorithm osa = new OrderedSchedulingAlgorithm( (ArrayList<JobDTO>)jobs.clone(), Integer.parseInt(args[1]) );
        osa.doGreedyScheduling( false );
        Iterator it = osa.getJobs().iterator();
        System.out.print( "- List of time from jobs: " );
        while( it.hasNext() ){
            System.out.print( ((JobDTO)it.next()).getTime()+"," );
        }
        System.out.println( "\ndone. Results:" );
        System.out.println( osa.getResult() );
        osa = new OrderedSchedulingAlgorithm( (ArrayList<JobDTO>)jobs.clone(), Integer.parseInt(args[1]) );
        osa.doGreedyScheduling( true );
        it = osa.getJobs().iterator();
        System.out.print( "- List of time from jobs: " );
        while( it.hasNext() ){
            System.out.print( ((JobDTO)it.next()).getTime()+"," );
        }
        System.out.println( "\ndone. Results:" );
        System.out.println( osa.getResult() );
    }
    
}
